package org.jrfe.gfx.g2d.shapes;

import org.jrfe.res.Texture;

public class MappedTexture {

	protected Texture texture;
	
	protected int x;
	protected int y;
	protected int width;
	protected int height;
	
	protected float mapMinX;
	protected float mapMinY;
	protected float mapMaxX;
	protected float mapMaxY;
	
	protected float mapWidth;
	protected float mapHeight;
	
	public MappedTexture(Texture texture) {
		this(texture, 0, 0, texture.getWidth(),texture.getHeight());
	}

	public MappedTexture(Texture texture, int x, int y, int width, int height) {
		this.texture = texture;
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
		
		mapMinX = x * texture.getSRatio();
		mapMinY = y * texture.getTRatio(); 
		mapMaxX = (x+width) * texture.getSRatio();
		mapMaxY = (y+height) * texture.getTRatio();
		
		mapWidth = mapMaxX - mapMinX;
		mapHeight = mapMaxY - mapMinY;
	
	}

	public Texture getTexture() {
		return texture;
	}

	public void setTexture(Texture texture) {
		this.texture = texture;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
		mapMinX = x * texture.getSRatio();
		//mapMinY = 1.f - y * texture.getTRatio(); 
		mapMaxX = (x+width) * texture.getSRatio();
		//mapMaxY = 1.f - (y+height) * texture.getTRatio(); 
		mapWidth = mapMaxX - mapMinX;
		//mapHeight = mapMaxY - mapMinY;

	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
		//mapMinX = x * texture.getSRatio();
		mapMinY = y * texture.getTRatio(); 
		//mapMaxX = (x+width) * texture.getSRatio();
		mapMaxY = (y+height) * texture.getTRatio(); 
		//mapWidth = mapMaxX - mapMinX;
		mapHeight = mapMaxY - mapMinY;

	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
		//mapMinX = x * texture.getSRatio();
		//mapMinY = 1.f - y * texture.getTRatio(); 
		mapMaxX = (x+width) * texture.getSRatio();
		//mapMaxY = 1.f - (y+height) * texture.getTRatio(); 
		mapWidth = mapMaxX - mapMinX;
		//mapHeight = mapMaxY - mapMinY;

	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
		//mapMinX = x * texture.getSRatio();
		//mapMinY = 1.f - y * texture.getTRatio(); 
		//mapMaxX = (x+width) * texture.getSRatio();
		mapMaxY = (y+height) * texture.getTRatio(); 
		
		//mapWidth = mapMaxX - mapMinX;
		mapHeight = mapMaxY - mapMinY;

	}

	public float getMapMinX() {
		return mapMinX;
	}

	public float getMapMinY() {
		return mapMinY;
	}

	public float getMapMaxX() {
		return mapMaxX;
	}

	public float getMapMaxY() {
		return mapMaxY;
	}
	
	public float getMapHeight() {
		return mapHeight;
	}
	
	public float getMapWidth() {
		return mapWidth;
	}
	
	
	
	
	
}
